// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: listener code decoupling
// feature: agent for vbs
// feature: add fast heartbeat feature
// feature: simplify xml profile
// feature: support batch send
// feature: E2E protection
// ------------------------------------------------------------------

#ifndef XMLPARSER_WRITERQOS_HPP_
#define XMLPARSER_WRITERQOS_HPP_

#include <xmlparser/qos/XMLQosPolicies.hpp>

namespace vbsutil {
namespace xmlparser {

/**
 * Class WriterQos, containing all the possible Qos that can be set for a determined Publisher.
 * Although these values can be set and are transmitted
 * during the Endpoint Discovery Protocol, not all of the behaviour associated with them has been
 * implemented in the library. Please consult each of them to check for implementation details and
 * default values.
 * @ingroup ERTPS_ATTRIBUTES_MODULE
 */
class WriterQos : public BaseWriterQos {
 public:
    RTPS_DllAPI WriterQos();
    RTPS_DllAPI virtual ~WriterQos();

    bool operator==(const WriterQos& b) const {
        return (this->m_durability == b.m_durability) && (this->m_deadline == b.m_deadline) &&
               (this->m_liveliness == b.m_liveliness) && (this->m_reliability == b.m_reliability) &&
               (this->m_ownership == b.m_ownership) && (this->m_ownershipStrength == b.m_ownershipStrength) &&
               (this->m_partition == b.m_partition) && (this->m_publishMode == b.m_publishMode) &&
               (this->m_lifespan == b.m_lifespan) && (this->m_disablePositiveACKs == b.m_disablePositiveACKs) &&
               (this->m_e2eProtecion == b.m_e2eProtecion) && (this->m_batch == b.m_batch) &&
               (this->m_resourceLimits == b.m_resourceLimits) && (this->m_history == b.m_history) &&
               (this->m_isMultiSend == b.m_isMultiSend) && (m_ipc_mode == b.m_ipc_mode) &&
               (m_agent_flag == b.m_agent_flag);
    }

    //! Durability Qos, implemented in the library.
    DurabilityQosPolicy m_durability;

    //! Deadline Qos, implemented in the library.
    DeadlineQosPolicy m_deadline;

    //! Liveliness Qos, implemented in the library.
    LivelinessQosPolicy m_liveliness;

    //! Reliability Qos, implemented in the library.
    ReliabilityQosPolicy m_reliability;

    //! Ownership Qos, implemented in the library.
    OwnershipQosPolicy m_ownership;

    //! Owenership Strength Qos, implemented in the library.
    OwnershipStrengthQosPolicy m_ownershipStrength;

    //! Partition Qos, implemented in the library.
    PartitionQosPolicy m_partition;

    //! Publication Mode Qos, implemented in the library.
    PublishModeQosPolicy m_publishMode;

    LifespanQosPolicy m_lifespan;

    //! Disable positive acks QoS, implemented in the library.
    DisablePositiveACKsQosPolicy m_disablePositiveACKs;

    //! E2E Protection QoS implemented in the library.
    E2EProtectionQosPolicy m_e2eProtecion;

    BatchQosPolicy m_batch;

    bool m_isMultiSend = false;

    HistoryQosPolicy m_history;

    ResourceLimitsQosPolicy m_resourceLimits;

    //! Disable heartbeat piggyback mechanism.
    bool disable_heartbeat_piggyback = false;

    uint8_t m_ipc_mode = 0;

    uint8_t m_agent_flag = 0;

    int32_t heartbeat_per_max_samples = 0;

    //When unack sample counts exceeds high_watermark, change to fast heartbeat period.
    int32_t high_watermark = -1;
    //When unack sample counts fall below high_watermark, change to heartbeat period.
    int32_t low_watermark = -1;

    /**
     * Set Qos from another class
     * @param qos Reference from a WriterQos object.
     * @param first_time Boolean indicating whether is the first time (If not some parameters cannot
     * be set).
     */
    RTPS_DllAPI void setQos(const WriterQos& qos, bool first_time);

    RTPS_DllAPI bool canQosBeUpdated(const WriterQos& qos) const;

    void clear();
};

}  // namespace xmlparser
}  // namespace vbsutil

#endif  // INCLUDE_EDDS_DDS_PUBLISHER_QOS_WRITERQOS_HPP_
